<!doctype html>
<html lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9,IE=8">
    <meta name="baidu-site-verification" content="dIcXMeY8Ya">
    
    <title>myql集群搭建 | blog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="keywords" content="Jim, 服务端, Java, Java开发">
    <meta name="description" content="Jim个人学习记录">

    
    <link rel="alternative" href="/atom.xml" title="blog" type="application/atom+xml">
    
    
    <link rel="shortcut icon" href="/favicon.ico">
    
    <link rel="stylesheet" href="/css/style.css">
    <!--[if lt IE 9]>
    <script src="/js/html5.js"></script>
    <![endif]-->
    
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?fd459238242776d173cdc64918fb32f2";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>


</head>
</html>
<body class="home">
    <!--[if lt IE 9]>
    <div class="browsehappy">
        当前网页 <strong>不支持</strong>
        你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>.
    </div>
    <![endif]-->

    <!-- 博客头部 -->
    <header class="header">
    <section class="container header-main">
        <div class="logo">
            <a href="/">
                <div class="cover">
                    <span class="name">blog</span>
                    <span class="description"></span>
                </div>
            </a>
        </div>
        <div class="dropnav icon-paragraph-justify" id="JELON__btnDropNav"></div>
        <ul class="menu hidden" id="JELON__menu">
            
            <li rel="/2019/03/05/myql集群搭建/index.html" class="item ">
                <a href="/" title="首页" class="icon-home">&nbsp;首页</a>
            </li>
            
            <li rel="/2019/03/05/myql集群搭建/index.html" class="item ">
                <a href="/about/" title="关于" class="icon-about">&nbsp;关于</a>
            </li>
            
            <li rel="/2019/03/05/myql集群搭建/index.html" class="item ">
                <a href="/comment/" title="留言" class="icon-comment">&nbsp;留言</a>
            </li>
            
        </ul>
        <div class="profile clearfix">
            <div class="feeds fl">
                
                
                <p class="links">
                    
                        <a href="https://github.com/starryming" target="_blank">Github</a>
                        |
                    
                        <a href="http://ljmstarry.gitee.io" target="_blank">Hosted by Coding Pages</a>
                        
                    
                </p>
                <p class="sns">
                    
                        <a href="http://weibo.com/" class="sinaweibo" target="_blank"><b>■</b> 新浪微博</a>
                    
                        <a href="https://www.facebook.com/" class="qqweibo" target="_blank"><b>■</b> Facebook</a>
                    
                    <a href="javascript: void(0);" class="wechat">
                        <b>■</b>
                        公众号
                        <span class="popover">
                            <img src="/img/wechat_mp.jpg" width="120" height="120" alt="我的微信订阅号">
                            <i class="arrow"></i>
                        </span>
                    </a>
                </p>
                
            </div>
            <div class="avatar fr">
                <img src="/img/timg.jpg" alt="avatar" title="Jim">
            </div>
        </div>
    </section>
</header>


    <!-- 博客正文 -->
    <div class="container body clearfix">
        <section class="content">
            <div class="content-main widget">
                <!-- 文章页 -->
<!-- 文章 -->
<article class="post article">
    <header class="text-center">
        <h3 class="post-title"><span>myql集群搭建</span></h3>
    </header>
    <p class="post-meta text-center">
        Jim 发表于
        <time datetime="2019-03-05T09:24:07.000Z">2019-03-05</time>
    </p>
    <div class="post-content">
        <p>搭建mysql集群 / 主从备</p>
<h4 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h4><table>
<thead>
<tr>
<th>tar包</th>
<th>路径</th>
</tr>
</thead>
<tbody>
<tr>
<td>mysql5.7.11</td>
<td><a href="http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz" target="_blank" rel="noopener">http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz</a></td>
</tr>
</tbody>
</table>
<a id="more"></a>
<h4 id="预期结果"><a href="#预期结果" class="headerlink" title="预期结果"></a>预期结果</h4><p><img src="https://ws1.sinaimg.cn/large/006f2SyGly1fzbuvujq1zj30d208a3yi.jpg" alt></p>
<h4 id="注意点"><a href="#注意点" class="headerlink" title="注意点"></a>注意点</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1</span>、主从备mysql版本最好一致</span><br><span class="line"><span class="number">2</span>、server_id设置不能相同</span><br><span class="line"><span class="number">3</span>、空库配置主从备，或者数据应该一致的状态下</span><br></pre></td></tr></table></figure>
<hr>
<h4 id="mysql-安装配置"><a href="#mysql-安装配置" class="headerlink" title="mysql 安装配置"></a>mysql 安装配置</h4><h6 id="1、利用xftp上传tar到-usr-local"><a href="#1、利用xftp上传tar到-usr-local" class="headerlink" title="1、利用xftp上传tar到 /usr/local/"></a>1、利用xftp上传tar到 /usr/local/</h6><h6 id="2、解压并重命名"><a href="#2、解压并重命名" class="headerlink" title="2、解压并重命名"></a>2、解压并重命名</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local</span><br><span class="line">tar -zxvf mysql-<span class="number">5.7</span>.11-linux-glibc2.5-x86_64.tar.gz  <span class="comment">//解压到当前文件</span></span><br><span class="line">mv mysql-<span class="number">5.7</span>.11-linux-glibc2.5-x86_64 mysql	<span class="comment">// 重命名</span></span><br></pre></td></tr></table></figure>
<h6 id="3、创建data目录"><a href="#3、创建data目录" class="headerlink" title="3、创建data目录"></a>3、创建data目录</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd mysql</span><br><span class="line">mkdir data</span><br></pre></td></tr></table></figure>
<h6 id="4、用户组-用户-添加"><a href="#4、用户组-用户-添加" class="headerlink" title="4、用户组/用户 添加"></a>4、用户组/用户 添加</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">groupadd mysql  <span class="comment">// 添加用户组</span></span><br><span class="line">useradd -r -g mysql mysql  <span class="comment">// 添加用户</span></span><br><span class="line">chown -R mysql:mysql ./	  <span class="comment">//修改当前目录拥有者为新建的mysql用户</span></span><br></pre></td></tr></table></figure>
<h6 id="5、安装"><a href="#5、安装" class="headerlink" title="5、安装"></a>5、安装</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize	 <span class="comment">//安装mysql</span></span><br></pre></td></tr></table></figure>
<h6 id="6、任何目录都可启动服务"><a href="#6、任何目录都可启动服务" class="headerlink" title="6、任何目录都可启动服务"></a>6、任何目录都可启动服务</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cp -a ./support-files/my-<span class="keyword">default</span>.cnf /etc/my.cnf	<span class="comment">// 复制配置文件到 /etc/my.cnf</span></span><br><span class="line">cp -a ./support-files/mysql.server /etc/init.d/mysqld  <span class="comment">// mysql进程放入系统进程</span></span><br><span class="line">ln -s /usr/local/mysql/ /usr/bin/	<span class="comment">// 创建ln</span></span><br><span class="line">service mysqld start	<span class="comment">// 启动服务</span></span><br></pre></td></tr></table></figure>
<h6 id="7、环境配置-设置环境变量后，任意目录可执行mysql-uroot-p"><a href="#7、环境配置-设置环境变量后，任意目录可执行mysql-uroot-p" class="headerlink" title="7、环境配置(设置环境变量后，任意目录可执行mysql -uroot -p)"></a>7、环境配置(设置环境变量后，任意目录可执行mysql -uroot -p)</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">vi /etc/profile</span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">	...</span></span><br><span class="line"><span class="comment">	//编辑的系统环境变量放在java环境变量后</span></span><br><span class="line"><span class="comment">	export PATH=$PATH:/usr/local/mysql/bin</span></span><br><span class="line"><span class="comment">	...</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line">source /etc/profile   <span class="comment">// 配置生效</span></span><br></pre></td></tr></table></figure>
<h6 id="8、修改密码"><a href="#8、修改密码" class="headerlink" title="8、修改密码"></a>8、修改密码</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mysql -u root -p	<span class="comment">// 后输入上面记录的随机密码</span></span><br><span class="line">alter user <span class="string">'root'</span>@<span class="string">'localhost'</span> identified by <span class="string">'password'</span>;	<span class="comment">// root 密码为 password</span></span><br><span class="line">flush privileges;	<span class="comment">// 刷新权限</span></span><br></pre></td></tr></table></figure>
<h6 id="9、远程连接允许"><a href="#9、远程连接允许" class="headerlink" title="9、远程连接允许"></a>9、远程连接允许</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">use mysql;</span><br><span class="line">update user set user.Host=<span class="string">'%'</span> where user.User=<span class="string">'root'</span>;	<span class="comment">// 允许远程连接数据库</span></span><br><span class="line">flush privileges;	<span class="comment">// 刷新权限</span></span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl stop firewalld.service	<span class="comment">// 关闭防火墙</span></span><br></pre></td></tr></table></figure>
<hr>
<h4 id="mysql-主从备配置"><a href="#mysql-主从备配置" class="headerlink" title="mysql 主从备配置"></a>mysql 主从备配置</h4><h5 id="主配置"><a href="#主配置" class="headerlink" title="主配置:"></a>主配置:</h5><h6 id="1、主服务my-cnf配置"><a href="#1、主服务my-cnf配置" class="headerlink" title="1、主服务my.cnf配置"></a>1、主服务my.cnf配置</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/my.cnf</span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 对my.cnf配置  上述docker安装配置时，已经提前配置</span></span><br><span class="line">[mysqld]</span><br><span class="line">log-bin=mysql-bin   <span class="comment">// [必须]启用二进制日志</span></span><br><span class="line">server-id=<span class="number">1</span>      <span class="comment">// [必须]服务器唯一ID，默认是1，一般取IP最后一段</span></span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service mysqld restart <span class="comment">// 重启服务</span></span><br></pre></td></tr></table></figure>
<h6 id="2、授权slave账号"><a href="#2、授权slave账号" class="headerlink" title="2、授权slave账号"></a>2、授权slave账号</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 主服务器上建立帐户并授权slave</span></span><br><span class="line">GRANT replication slave ON *.* TO <span class="string">'slave'</span>@<span class="string">'%'</span> IDENTIFIED BY <span class="string">'password'</span>; </span><br><span class="line"></span><br><span class="line">show variables like <span class="string">'server_id'</span>;  <span class="comment">// 查看server_id</span></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">+---------------+-------+</span></span><br><span class="line"><span class="comment">| Variable_name | Value |</span></span><br><span class="line"><span class="comment">+---------------+-------+</span></span><br><span class="line"><span class="comment">| server_id     | 1     |</span></span><br><span class="line"><span class="comment">+---------------+-------+</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line">flush tables with read lock; <span class="comment">// 锁定表，防止主服务器状态值变化</span></span><br><span class="line"></span><br><span class="line">show master status;	 <span class="comment">// 查看二进制日志 log-bin=mysql-bin 没配置将查询为空 配置从服务器要用</span></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">+------------------+----------+--------------+------------------+-------------------+</span></span><br><span class="line"><span class="comment">| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |</span></span><br><span class="line"><span class="comment">+------------------+----------+--------------+------------------+-------------------+</span></span><br><span class="line"><span class="comment">| mysql-bin.000001 |      154 |              |                  |                   |</span></span><br><span class="line"><span class="comment">+------------------+----------+--------------+------------------+-------------------+</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line">unlock tables;  <span class="comment">// 配置都完了后进行解锁表</span></span><br></pre></td></tr></table></figure>
<h5 id="从配置"><a href="#从配置" class="headerlink" title="从配置:"></a>从配置:</h5><h6 id="1、my-cnf基本配置"><a href="#1、my-cnf基本配置" class="headerlink" title="1、my.cnf基本配置"></a><strong>1、my.cnf基本配置</strong></h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 对my.cnf配置  上述docker安装配置时，已经提前配置</span></span><br><span class="line">[mysqld]</span><br><span class="line">server-id=<span class="number">2</span>      <span class="comment">//[必须]服务器唯一ID</span></span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service mysqld restart <span class="comment">// 重启服务</span></span><br></pre></td></tr></table></figure>
<h6 id="2、从服务slave配置"><a href="#2、从服务slave配置" class="headerlink" title="2、从服务slave配置"></a>2、从服务slave配置</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">show variables like <span class="string">'server_id'</span>;  <span class="comment">// 查看server_id,预防配置未生效  server_id重复</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 从服务器配置 ： 注意不要断开，308数字前后无单引号。</span></span><br><span class="line">change master to master_host=<span class="string">'ip地址'</span>, master_user=<span class="string">'slave'</span>, master_password=<span class="string">'password'</span>,master_log_file=<span class="string">'mysql-bin.000001'</span>,master_log_pos=<span class="number">430</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">master_host='ip地址'		主服务器ip	</span></span><br><span class="line"><span class="comment">master_user='slave'			主服务器slave账号</span></span><br><span class="line"><span class="comment">master_password='password'			主服务器slave密码</span></span><br><span class="line"><span class="comment">master_log_file='mysql-bin.000001'			binlog名</span></span><br><span class="line"><span class="comment">master_log_pos=430			binlog记录位置</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line">- start slave;    <span class="comment">//启动从服务器复制功能</span></span><br></pre></td></tr></table></figure>
<h6 id="3、检查从服务器功能状态"><a href="#3、检查从服务器功能状态" class="headerlink" title="3、检查从服务器功能状态"></a>3、检查从服务器功能状态</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">show slave status\G</span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">   *************************** 1. row ***************************</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">              Slave_IO_State: Waiting for master to send event</span></span><br><span class="line"><span class="comment">              Master_Host: ip地址  //主服务器地址</span></span><br><span class="line"><span class="comment">              Master_User: slave   //授权帐户名，尽量避免使用root</span></span><br><span class="line"><span class="comment">              Master_Port: 3306    //数据库端口</span></span><br><span class="line"><span class="comment">              Connect_Retry: 60</span></span><br><span class="line"><span class="comment">              Master_Log_File: mysql-bin.000001</span></span><br><span class="line"><span class="comment">              Read_Master_Log_Pos: 430     //#同步读取二进制日志的位置，大于等于Exec_Master_Log_Pos</span></span><br><span class="line"><span class="comment">              Relay_Log_File: techtrain29-test1-rgtj1-tj1-relay-bin.000002</span></span><br><span class="line"><span class="comment">              Relay_Log_Pos: 320</span></span><br><span class="line"><span class="comment">              Relay_Master_Log_File: mysql-bin.000001</span></span><br><span class="line"><span class="comment">              Slave_IO_Running: Yes    //此状态必须YES</span></span><br><span class="line"><span class="comment">              Slave_SQL_Running: Yes     //此状态必须YES</span></span><br><span class="line"><span class="comment">                    ......</span></span><br><span class="line"><span class="comment">注：Slave_IO及Slave_SQL进程必须正常运行，即YES状态，否则都是错误的状态(如：其中一个NO均属错误)。</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>
<h6 id="4、从库只读"><a href="#4、从库只读" class="headerlink" title="4、从库只读"></a>4、从库只读</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">show global variables like <span class="string">"%read_only%"</span>;	<span class="comment">// 查看状态</span></span><br><span class="line">set global read_only=<span class="number">1</span>;		<span class="comment">// 修改只读</span></span><br><span class="line">show global variables like <span class="string">"%read_only%"</span>;</span><br><span class="line"></span><br><span class="line">flush privileges;	<span class="comment">// 更新</span></span><br></pre></td></tr></table></figure>
<h5 id="mysql备配置"><a href="#mysql备配置" class="headerlink" title="mysql备配置"></a>mysql备配置</h5><p>​    同从配置</p>
<h4 id="数据异常解决方案"><a href="#数据异常解决方案" class="headerlink" title="数据异常解决方案"></a>数据异常解决方案</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 0、查看各库日志，选择日志大的作为同步点。主库为同步点样例：</span></span><br><span class="line">show master logs;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 1、主库锁库，防止操作，日志变动。</span></span><br><span class="line">flush tables with read lock; 	<span class="comment">// 结束记得解锁 unlock tables;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 2、从库查看slave状态</span></span><br><span class="line">show slave status\G;</span><br><span class="line">stop slave；	<span class="comment">// 停止slave</span></span><br><span class="line">reset master; <span class="comment">// 清空日志</span></span><br><span class="line">reset slave;  <span class="comment">// 重置slave</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 3、利用navicate传输数据：主——&gt;从 (或使用命令导出sql)</span></span><br><span class="line">    </span><br><span class="line"><span class="comment">// 4、从库配置 配置同步点</span></span><br><span class="line">change master to master_host=<span class="string">'ip地址'</span>, master_user=<span class="string">'slave'</span>, master_password=<span class="string">'password'</span>,master_log_file=<span class="string">'mysql-bin.000001'</span>,master_log_pos=<span class="number">526962</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 5、查看状态</span></span><br><span class="line">show slave status\G;</span><br></pre></td></tr></table></figure>

    </div>
    <p class="post-meta">
        <span class="post-cat">分类：
            <a class="cat-link" href="/categories/linus/">linus</a>
        </span>
        <span class="post-tags">
            标签：
            
    
        <a href="/tags/linus/" title="linus">linus</a> / 
    
        <a href="/tags/mysql/" title="mysql">mysql</a>
    

        </span>
    </p>
</article>
<!-- 分享按钮 -->

  <div class="article-share clearfix text-center">
    <div class="share-area">
      <span class="share-txt">分享到：</span>
      <a href="javascript: window.open('http://service.weibo.com/share/share.php?url=' + encodeURIComponent(location.href) + '&title=' + document.title + '&language=zh_cn');" class="share-icon weibo"></a>
      <a href="javascript: alert('请复制链接到微信并发送');" class="share-icon wechat"></a>
      <a href="javascript: window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(location.href) + '&title=' + document.title);" class="share-icon qqzone"></a>
      <a href="javascript: window.open('http://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location.href) + '&desc=Jim个人博客&title=' + document.title + '&callback=' + encodeURIComponent(location.href));" class="share-icon qq"></a>
      <a href="javascript: window.open('http://shuo.douban.com/!service/share?href=' + encodeURIComponent(location.href) + '&name=' + document.title + '&text=' + document.title);" class="share-icon douban"></a>
    </div>
  </div>


<!-- 上一篇/下一篇 -->

<div class="article-nav clearfix">
    
    <span class="prev fl">
        上一篇<br>
        <a href="/2019/04/09/SSM图片上传/">
            
                SSM图片上传
            
        </a>
    </span>
    

    
    <span class="next fr">
        下一篇<br>
        <a href="/2019/03/05/Nginx服务器搭建/">
            
                Nginx服务器搭建
            
        </a>
    </span>
    
</div>

<!-- 文章评论 -->

  <script src="/js/comment.js"></script>
  <div id="comments" class="comment">
    <!--
    <div class="sign-bar">
      GitHub 已登录!
      <span class="sign-link">登出</span>
    </div>
    <section class="box">
      <div class="com-avatar"><img src="/img/jelon.jpg" alt="avatar"></div>
      <div class="com-text">
        <div class="main">
          <textarea class="text-area-edited show" placeholder="欢迎评论！"></textarea>
          <div class="text-area-preview"></div>
        </div>
        <div class="switch">
          <div class="switch-item on">编辑</div>
          <div class="switch-item">预览</div>
        </div>
        <div class="button">提交</div>
      </div>
    </section>
    <section class="tips">注：评论支持 markdown 语法！</section>
    <section class="list-wrap">
      <ul class="list">
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">张德龙</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like liked">已赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">333333</div>
          </div>
        </li>
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">刘德华</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like">点赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">vvvvv</div>
          </div>
        </li>
      </ul>
      <div class="page-nav">
        <a href="javascript: void(0);" class="item">1</a>
        <a href="javascript: void(0);" class="item">2</a>
        <a href="javascript: void(0);" class="item current">3</a>
      </div>
    </section>
    -->
  </div>
  <script>
  JELON.Comment({
    container: 'comments',
    label: 'myql集群搭建' || '2019/03/05/myql集群搭建/',
    owner: 'your_github_id',
    repo: 'your_blog_comments',
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret'
  });
  </script>


            </div>

        </section>
        <!-- 侧栏部分 -->
<aside class="sidebar">
    <section class="widget">
        <h3 class="widget-hd"><strong>文章分类</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
    <li>
        <a href="/categories/linus/">linus</a>
        <span class="badge">(4)</span>
    </li>
    
    <li>
        <a href="/categories/technology/">technology</a>
        <span class="badge">(8)</span>
    </li>
    
    <li>
        <a href="/categories/Reading/">Reading</a>
        <span class="badge">(13)</span>
    </li>
    
    <li>
        <a href="/categories/others/">others</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/categories/linus/technology/">technology</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/categories/mysql/">mysql</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/categories/mysql/technology/">technology</a>
        <span class="badge">(1)</span>
    </li>
    
</ul>
    </section>

    
    <section class="widget">
        <h3 class="widget-hd"><strong>热门标签</strong></h3>
        <!-- 文章标签 -->
<div class="widget-bd tag-wrap">
  
    <a class="tag-item" href="/tags/linus/" title="linus">linus (4)</a>
  
    <a class="tag-item" href="/tags/ngnix/" title="ngnix">ngnix (1)</a>
  
    <a class="tag-item" href="/tags/源码学习/" title="源码学习">源码学习 (2)</a>
  
    <a class="tag-item" href="/tags/阅读/" title="阅读">阅读 (13)</a>
  
    <a class="tag-item" href="/tags/Thinking-In-Java/" title="Thinking In Java">Thinking In Java (5)</a>
  
    <a class="tag-item" href="/tags/java/" title="java">java (3)</a>
  
    <a class="tag-item" href="/tags/technology/" title="technology">technology (1)</a>
  
    <a class="tag-item" href="/tags/springBoot/" title="springBoot">springBoot (2)</a>
  
    <a class="tag-item" href="/tags/设计模式/" title="设计模式">设计模式 (3)</a>
  
    <a class="tag-item" href="/tags/test/" title="test">test (1)</a>
  
    <a class="tag-item" href="/tags/Effective-Java/" title="Effective Java">Effective Java (8)</a>
  
    <a class="tag-item" href="/tags/mysql/" title="mysql">mysql (2)</a>
  
    <a class="tag-item" href="/tags/Docker/" title="Docker">Docker (1)</a>
  
</div>
    </section>
    

    

    
    <!-- 友情链接 -->
    <section class="widget">
        <h3 class="widget-hd"><strong>友情链接</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
        <li>
            <a href="https://www.bilibili.com" target="_blank" title="bilibili">哔哩哔哩</a>
        </li>
    
        <li>
            <a href="https://www.baidu.com" target="_blank" title="百度搜索">百度</a>
        </li>
    
</ul>
    </section>
    
</aside>
<!-- / 侧栏部分 -->
    </div>

    <!-- 博客底部 -->
    <footer class="footer">
    &copy;
    
        2016-2020
    

    <a href="/">Jim Loves You</a>
</footer>
<div class="back-to-top" id="JELON__backToTop" title="返回顶部">返回顶部</div>

    <!--博客js脚本 -->
    <!-- 这里放网站js脚本 -->
<script src="/js/main.js"></script>
</body>
</html>